package com.wude.guild.holder;

import android.app.Activity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mc.developmentkit.utils.MCUtils;
import com.wude.bean.StartFuBean;
import com.wude.guild.R;
import com.wude.tools.Utils;

import org.xutils.x;

import java.text.SimpleDateFormat;
import java.util.Date;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 游戏详情内区服信息
 * Created by Administrator on 2017/3/24.
 */

public class GameDetQufuHolder extends BaseHolder<StartFuBean> {
    @BindView(R.id.time_shi)
    TextView timeShi;
    @BindView(R.id.time_nyr)
    TextView timeNyr;
    @BindView(R.id.qufu)
    TextView qufu;
    @BindView(R.id.zhuangtai)
    TextView zhuangtai;

    @Override
    protected void refreshView(StartFuBean startFuBean, int position, Activity activity) {
        qufu.setText(startFuBean.qu);
        boolean fu = Utils.getFu(startFuBean.time);
        if (fu) {
            zhuangtai.setText("已开服");
            zhuangtai.setTextColor(x.app().getResources().getColor(R.color.dialog_title));
        } else {
            zhuangtai.setText("即将开服");
            zhuangtai.setTextColor(x.app().getResources().getColor(R.color.zi_lan));
        }
        String dataYMD = MCUtils.getDataYMD(startFuBean.time);
        timeNyr.setText(dataYMD);
        String dataHM = getDataHM(startFuBean.time);
        timeShi.setText(dataHM);
    }

    @Override
    protected View initView() {
        View inflate = LinearLayout.inflate(x.app(), R.layout.holder_gamedet_qufu, null);
        ButterKnife.bind(this, inflate);
        inflate.setTag(this);
        return inflate;
    }

    public static String getDataHM(String time) {
        if (!time.equals("")) {
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
            String sd = sdf.format(new Date(Long.parseLong(time) * 1000L));
            return sd;
        } else {
            return "";
        }
    }
}
